<template>
	<view class="container" @touchmove.stop.prevent="() => {}">
		<u-navbar leftText=" " title=" " :safeAreaInsetTop="true" :placeholder="true">
			<view class="u-nav-slot" slot="left" @click="left">
				<u-icon name="arrow-left" color="#000000" size="16" :bold="true"></u-icon>
			</view>

		</u-navbar>
		<image class="bg-c" src="../../static/images/bg-c.png"></image>
		<view class="sign-up-title-c">
			<image class="bg1-l" src="../../static/images/left.png" mode="widthFix"></image>
			<image class="bg2-2" src="../../static/images/right.png" mode="widthFix"></image>
			<view class="sign-up-title-item">
				<view class="yexy">
					请选择期望的结婚年份
				</view>
			</view>
			<view class="sign-up-title-tips" style="color: rgba(0, 0, 0, 0);">
				.
			</view>
		</view>
		<view class="select-c">
			<picker-view @change="bindChange" :mask-style="fsdfds" class="picker-view" :indicator-style="indicatorStyle"
				indicator-class="indicator-class">
				<picker-view-column>
					<view class="item" v-for="(item,index) in listArr" :key="index" :class="val==item.code?'lldl':''">
						{{item.value}}
					</view>
				</picker-view-column>
			</picker-view>
		</view>
		<view class="to-btn" @click="stepToNext">
			注册
		</view>
	</view>
</template>

<script>
	var _self;
	import {
		sysDict,
		userRegister
	} from '@/common/api.js'
	export default {
		components: {},
		data() {
			// 最高学历 Specialty("专科"), \n Undergraduate("本科"), \n Master("硕士"), \n Doctor("博士")
			return {
				listArr: [],
				bgColor: 'rgba(0, 31, 63, 0)',
				val: "",
				indicatorStyle: `height: 41px;color: rgba(51, 51, 51, 0.2);`,
				fsdfds: `opacity: 0.1;background: rgba(238, 245, 254, 0);`,
				obj: {},
				gender: '',
				birthday: '',
				deptId: '',
				name: '',
				idcard: '',
				phone: '',
			};
		},
		onLoad(options) {
			_self = this;
			_self.birthday = options.birthday;
			_self.gender = options.gender;
			_self.birthday = options.birthday;
			_self.deptId = options.deptId;
			_self.name = options.name;
			_self.idcard = options.idcard;
			_self.phone = options.phone;
			_self.getEduList();
		},
		methods: {
			getEduList() {
				sysDict({
					code: 'want_marry'
				}).then(res => {
					_self.listArr = res.data;
					_self.val = _self.listArr[0].code;
				}).catch({

				})
			},
			left() {
				uni.navigateBack()
			},
			stepToNext() {
				// _self.obj.education = _self.val == '专科' ? 'Specialty' : _self.val == '本科' ? 'Undergraduate' : _self.val ==
				// 	'硕士' ? 'Master' : _self.val == '博士' ? 'Doctor' : ''
				// console.log(_self.val, _self.obj);
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						console.log("loginRes=", loginRes);
						userRegister({
							code: loginRes.code,
							sex: parseInt(_self.gender),
							birthday: _self.birthday,
							deptId: _self.deptId,
							name: _self.name,
							idcard: _self.idcard,
							phone: _self.phone,
							// img1: _self.imageId,
							marriageDate: _self.val
						}).then((res) => {
							console.log('res = ', res);
							if (res.code == 200) {
								uni.reLaunch({
									url: '/pageslogin/index/index'
								})
							} 
							// else {
							// 	_self.tipMsg = res.msg;
							// 	_self_selflfefs.elm.showDialog();
							// 	return
							// }

						}).catch(() => {

						})


					}
				});
				// uni.navigateTo({
				// 	url: '/pageslogin/index/avatar?gender=' + _self.gender +
				// 		'&birthday=' + _self
				// 		.birthday +
				// 		'&deptId=' + _self.deptId + '&name=' + _self.name +
				// 		'&idcard=' + _self.idcard + '&phone=' + _self
				// 		.phone + '&marryDate=' + _self.val
				// });

			},
			bindChange(val) {
				_self.val = _self.listArr[val.detail.value[0]].code
				console.log(val, _self.val);
			}
		}
	}
</script>

<style lang="scss">
	.bg-c {
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
		pointer-events: none;
	}

	page {
		width: 100%;
		height: 100%;
	}

	.container {
		position: relative;
		width: 100vw;
		height: 100%;
	}

	.sign-up-title-c {
		position: relative;
		width: 594rpx;
		height: 200rpx;
		margin: auto;
		margin-top: 52rpx;
		box-sizing: content-box;
		overflow: hidden;
		color: #333;

		.bg1-l {
			position: absolute;
			top: 0rpx;
			left: 10rpx;

			width: 95rpx;
			z-index: -1;
		}

		.bg2-2 {
			position: absolute;
			top: 66rpx;
			right: -10rpx;
			width: 83rpx;
			z-index: -1;
		}

		.sign-up-title-item {
			font-size: 48rpx;
			display: flex;
			align-items: center;
			margin-top: 66rpx;
			justify-content: center;
			font-family: 'SourceHanSerifCN-Heavy';

			.yexy {
				margin-left: -20rpx;
				color: rgba(45, 49, 50, 0.9);
				font-family: 'SourceHanSerifCN-Heavy';
			}
		}

		.sign-up-title-tips {
			text-align: center;
			margin-top: 24rpx;
			font-weight: 400;
			color: #666;
			font-size: 24rpx
		}
	}


	.select-c {
		position: relative;
		padding: 20rpx 0;



		.picker-view {
			height: 450rpx;
			margin: auto;

			color: #434343;
		}

		picker-view-column {
			.item {
				width: 100%;
				text-align: center;
				line-height: 41px;
				height: 41px;
				color: #B8B8B8;
				font-weight: 400;
				font-family: 'PingFang SC-Regular, PingFang SC';
			}

			.lldl {
				color: rgba(45, 49, 50, 0.9);
				font-family: 'PingFang SC-Bold, PingFang SC';


			}
		}
	}

	/deep/ .indicator-class {
		background: #EEF5FE;
		z-index: -1;
	}

	.to-btn {
		width: 536rpx;
		height: 84rpx;
		background: linear-gradient(86deg, #C2D2F9 0%, #C5C2F3 100%);
		border-radius: 42rpx 42rpx 42rpx 42rpx;
		text-align: center;
		line-height: 84rpx;
		margin: auto;
		position: fixed;
		bottom: 15vh;
		left: 112rpx;
		font-size: 28rpx;
		font-family: 'PingFang SC-Bold, PingFang SC';
		color: rgba(65, 92, 158, 0.9);
		font-weight: 400;
		font-size: 28rpx;
	}

	.tips {
		margin: auto;
		text-align: center;
		margin-top: 30rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #B7B7B7;
	}
</style>